#!/usr/bin/python
# -*- coding: UTF-8 -*-
import time   # 引入time模块
ticks = time.time()
print("当前时间戳为:", ticks)

localtime = time.localtime(time.time())
print("本地时间:", localtime)

localtimeas = time.asctime(time.localtime(time.time()))
print("本地时间:", localtimeas)


# 格式化成 xxxx-xx-xx xx:xx:xx 的形式
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))

# 格式化成 Sat Mar 28 22:22:22 2020 的形式
print(time.strftime("%a %b %d %H:%M:S %Y", time.localtime()))

# 将格式字符串转换为时间戳
a = "Sat Mar 28 22:24:24 2016"
print (time.mktime(time.strptime(a,"%a %b %d %H:%M:%S %Y")))